package toanstt.gameplay;

import toanstt.com.App;
import toanstt.com.Button;
import toanstt.com.DiamondLinkinActivity;
import toanstt.com.SCR;
import toanstt.com.T;
import android.graphics.Canvas;
import android.util.Log;
import android.view.MotionEvent;

public class GamePannel
{
	int minx,miny,maxx,maxy;
	Button but_replay;
	Button but_menu;
	int temp_x,temp_y;
	int action,actionCode ;
	public GamePannel()
	{
		minx = T.PANEL_MIN_X;
		miny = T.PANEL_MIN_Y;
		maxx = T.PANEL_MAX_X;
		maxy = T.PANEL_MAX_Y;
		but_replay = new Button(T.bitmap_button_replay, (int)(minx + 6.5*T.UNIT), (int)(miny + 15*T.UNIT), 4*T.UNIT/80);	
		but_menu = new Button(T.bitmap_button_menu, (int)(minx + 6.5*T.UNIT), (int)(miny + 18.5*T.UNIT), 4*T.UNIT/80);
	}
	public void Draw(Canvas canvas)
	{
		T.bitmapFont[0].drawString(canvas,"SCORE : " +T.PLAY_SCORE,minx+(int)T.UNIT, (int)(miny+2*T.UNIT), 0);
		T.bitmapFont[1].drawString(canvas,"GOLD : " +T.PLAY_GOLD,minx+(int)T.UNIT, miny+4*(int)T.UNIT, 0);
		T.bitmapFont[0].drawString(canvas,"DIFFICULT : " +T.GAME_NUM_DIAMOND,minx+(int)T.UNIT, miny+(int)(7*T.UNIT), 0);
		if(T.PLAY_ISTAGE==true)
		{
			T.bitmapFont[1].drawString(canvas,"Stage : " +T.PLAY_CURRENTSTAGE,minx+(int)T.UNIT, miny+(int)(9*T.UNIT), 0);
			T.bitmapFont[0].drawString(canvas,"Require: " +(int)(GameManagement.timeline.MAXTIME),minx+(int)T.UNIT, miny+(int)(11*T.UNIT), 0);
		}
		else
			T.bitmapFont[0].drawString(canvas,"Recore : " +T.PLAY_BEST_CROCE,minx+(int)T.UNIT, miny+(int)(9.5*T.UNIT), 0);
		but_replay.Draw(canvas);			   
		but_menu.Draw(canvas);
	}
	public void touch(MotionEvent mo)
	{
		//Log.d("here", "ddddddd");
		action = mo.getAction();
		actionCode = action & MotionEvent.ACTION_MASK;
		temp_x = (int)mo.getX();
		temp_y = (int)mo.getY();
	
		if(but_replay.Kick(mo) == true)
		{
			if(T.PLAY_ISTAGE==true)
				App.gamemanagement.NewGame(T.PLAY_CURRENTSTAGE, 1, 4);
			else
				App.gamemanagement.NewGame(0, 60, 4);
			T.SCREEN = SCR.GAME;
			
			return;
		}
		else if(but_menu.Kick(mo) == true)
		{
			but_replay.anpla = 255;
			T.sound1.Pause();
			App.mainframe.ResetAllMouseAlpha();
			T.SCREEN = SCR.MENU;
			return;
		}
		else
			but_menu.anpla = 255;
		
		if(actionCode == MotionEvent.ACTION_UP)
		{
			but_replay.anpla = 255;
			but_menu.anpla = 255;
		}
	}
}
